//
//  SetYongJinViewController.m
//  PlayBall
//
//  Created by yanfa on 16/4/23.
//
//

#import "SetYongJinViewController.h"
#import "AppDelegate.h"

@interface SetYongJinViewController ()

@end

@implementation SetYongJinViewController
@synthesize subuserid;

//SHARED_VIEW_CONTROLLER_IMPLEMENT(SetYongJinViewController)
UITapGestureRecognizer * _gesture;


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
    customLab.backgroundColor = [UIColor clearColor];
    [customLab setText:@"设置佣金"];
    customLab.textAlignment = NSTextAlignmentCenter;
    
    [customLab setTextColor:[UIColor whiteColor]];
    customLab.font = [UIFont systemFontOfSize:19];
    self.navigationItem.titleView = customLab;
    //self.navigationItem.hidesBackButton = YES;
    GetYongJin *operation = [[GetYongJin alloc] init];
    operation.userid =
    subuserid;
//    [JddUserProfile sharedInstance].userId;
    operation.delegate = self;
    [[JddGlobalParameter sharedInstance].operationQueue addOperation:operation];
    
    _gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hidesKeyboard)];
    _gesture.enabled = NO;//最开始手势设为no
    [self.view addGestureRecognizer:_gesture];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillShow)
                                                 name:UIKeyboardWillShowNotification
                                               object:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)GetYongJinResult:(NSData *)result{
    [JddCommonFunction setWaitingViewHidden:YES fromController:self];
    if (result) {
        SBJsonParser *jsonParse = [[SBJsonParser alloc] init];
        NSString *realresult = [JddDataParser parseBuyHistoryDetailResult:result];
        NSDictionary *dataDic = [jsonParse objectWithString:realresult];
        datas = [dataDic objectForKey:@"Union"];
        for (int i=0; i<[datas count]; i++) {
            NSDictionary* item = [datas objectAtIndex:i];
            
     
            if(([[dataDic objectForKey:@"IsUnion"] boolValue] == false) && [[item objectForKey:@"RmdScale"] floatValue] - 2 > 0){
                switch (i) {
                    case 0:
                        [_label_name1 setText:[item objectForKey:@"LottName"]];
                        [_tf_1 setText:[NSString stringWithFormat:@"%.2f",[[item objectForKey:@"RmdScale"] floatValue] - 2]];
                        [_lb_1 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        break;
                    case 1:
                        [_label_name2 setText:[item objectForKey:@"LottName"]];
                        [_tf_2 setText:[NSString stringWithFormat:@"%.2f",[[item objectForKey:@"RmdScale"] floatValue] - 2]];
                        [_lb_2 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        break;
                    case 2:
                        [_label_name3 setText:[item objectForKey:@"LottName"]];
                        [_tf_3 setText:[NSString stringWithFormat:@"%.2f",[[item objectForKey:@"RmdScale"] floatValue] - 2]];
                        [_lb_3 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        break;
                    case 3:
                        [_label_name4 setText:[item objectForKey:@"LottName"]];
                        [_tf_4 setText:[NSString stringWithFormat:@"%.2f",[[item objectForKey:@"RmdScale"] floatValue] - 2]];
                        [_lb_4 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        break;
                    case 4:
                        [_label_name5 setText:[item objectForKey:@"LottName"]];
                        [_tf_5 setText:[NSString stringWithFormat:@"%.2f",[[item objectForKey:@"RmdScale"] floatValue] - 2]];
                        [_lb_5 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        break;
                    case 5:
                        [_label_name6 setText:[item objectForKey:@"LottName"]];
                        [_tf_6 setText:[NSString stringWithFormat:@"%.2f",[[item objectForKey:@"RmdScale"] floatValue] - 2]];
                        [_lb_6 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        break;
                    case 6:
                        [_label_name7 setText:[item objectForKey:@"LottName"]];
                        [_tf_7 setText:[NSString stringWithFormat:@"%.2f",[[item objectForKey:@"RmdScale"] floatValue] - 2]];
                        [_lb_7 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        break;
                    case 7:
                        [_label_name8 setText:[item objectForKey:@"LottName"]];
                        [_tf_8 setText:[NSString stringWithFormat:@"%.2f",[[item objectForKey:@"RmdScale"] floatValue] - 2]];
                        [_lb_8 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        break;

                }
            }else{
                switch (i) {
                    case 0:
                        [_label_name1 setText:[item objectForKey:@"LottName"]];
                        [_tf_1 setText:[item objectForKey:@"Scale"]];
                        [_lb_1 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        break;
                    case 1:
                        [_label_name2 setText:[item objectForKey:@"LottName"]];
                        [_tf_2 setText:[item objectForKey:@"Scale"]];
                        [_lb_2 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        break;
                    case 2:
                        [_label_name3 setText:[item objectForKey:@"LottName"]];
                        [_tf_3 setText:[item objectForKey:@"Scale"]];
                        [_lb_3 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        break;
                    case 3:
                        [_label_name4 setText:[item objectForKey:@"LottName"]];
                        [_tf_4 setText:[item objectForKey:@"Scale"]];
                        [_lb_4 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        break;
                    case 4:
                        [_label_name5 setText:[item objectForKey:@"LottName"]];
                        [_tf_5 setText:[item objectForKey:@"Scale"]];
                        [_lb_5 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        break;
                    case 5:
                        [_label_name6 setText:[item objectForKey:@"LottName"]];
                        [_tf_6 setText:[item objectForKey:@"Scale"]];
                        [_lb_6 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        break;
                    case 6:
                        [_label_name7 setText:[item objectForKey:@"LottName"]];
                        [_tf_7 setText:[item objectForKey:@"Scale"]];
                        [_lb_7 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        break;
                    case 7:
                        [_label_name8 setText:[item objectForKey:@"LottName"]];
                        [_tf_8 setText:[item objectForKey:@"Scale"]];
                        [_lb_8 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        break;
                        //                case 8:
                        //                    [_label_name9 setText:[item objectForKey:@"LottName"]];
                        //                    [_tf_9 setText:[item objectForKey:@"Scale"]];
                        //                    [_lb_9 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        //                    break;
                        //                case 9:
                        //                    [_label_name10 setText:[item objectForKey:@"LottName"]];
                        //                    [_tf_10 setText:[item objectForKey:@"Scale"]];
                        //                    [_lb_10 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        //                    break;
                        //                case 10:
                        //                    [_label_name11 setText:[item objectForKey:@"LottName"]];
                        //                    [_tf_11 setText:[item objectForKey:@"Scale"]];
                        //                    [_lb_11 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        //                    break;
                        //                case 11:
                        //                    [_label_name12 setText:[item objectForKey:@"LottName"]];
                        //                    [_tf_12 setText:[item objectForKey:@"Scale"]];
                        //                    [_lb_12 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        //                    break;
                        //                case 12:
                        //                    [_label_name13 setText:[item objectForKey:@"LottName"]];
                        //                    [_tf_13 setText:[item objectForKey:@"Scale"]];
                        //                    [_lb_13 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        //                    break;
                        //                case 13:
                        //                    [_label_name14 setText:[item objectForKey:@"LottName"]];
                        //                    [_tf_14 setText:[item objectForKey:@"Scale"]];
                        //                    [_lb_14 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        //                    break;
                        //                case 14:
                        //                    [_label_name15 setText:[item objectForKey:@"LottName"]];
                        //                    [_tf_15 setText:[item objectForKey:@"Scale"]];
                        //                    [_lb_15 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        //                    break;
                        //                case 15:
                        //                    [_label_name16 setText:[item objectForKey:@"LottName"]];
                        //                    [_tf_16 setText:[item objectForKey:@"Scale"]];
                        //                    [_lb_16 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        //                    break;
                        //                case 16:
                        //                    [_label_name17 setText:[item objectForKey:@"LottName"]];
                        //                    [_tf_17 setText:[item objectForKey:@"Scale"]];
                        //                    [_lb_17 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        //                    break;
                        //                case 17:
                        //                    [_label_name18 setText:[item objectForKey:@"LottName"]];
                        //                    [_tf_18 setText:[item objectForKey:@"Scale"]];
                        //                    [_lb_18 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        //                    break;
                        //                case 18:
                        //                    [_label_name19 setText:[item objectForKey:@"LottName"]];
                        //                    [_tf_19 setText:[item objectForKey:@"Scale"]];
                        //                    [_lb_19 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        //                    break;
                        //                case 19:
                        //                    [_label_name20 setText:[item objectForKey:@"LottName"]];
                        //                    [_tf_20 setText:[item objectForKey:@"Scale"]];
                        //                    [_lb_20 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        //                    break;
                        //                case 20:
                        //                    [_label_name21 setText:[item objectForKey:@"LottName"]];
                        //                    [_tf_21 setText:[item objectForKey:@"Scale"]];
                        //                    [_lb_21 setText:[NSString stringWithFormat:@"%%，自身佣金%@%%",[item objectForKey:@"RmdScale"]]];
                        //                    break;
                    default:
                        break;
                }
            }
        }
        bool isUnion = [[dataDic objectForKey:@"IsUnion"] boolValue];
        [_cb_isCMD setSelected:isUnion];
    }
}

-(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{

    [_tf_1 resignFirstResponder];
    [_tf_2 resignFirstResponder];
    [_tf_3 resignFirstResponder];
    [_tf_4 resignFirstResponder];
    [_tf_5 resignFirstResponder];
    [_tf_6 resignFirstResponder];
    [_tf_7 resignFirstResponder];
//    [_tf_8 resignFirstResponder];
//    [_tf_9 resignFirstResponder];
//    [_tf_9 resignFirstResponder];
//    [_tf_10 resignFirstResponder];
//    [_tf_11 resignFirstResponder];
//    [_tf_12 resignFirstResponder];
//    [_tf_13 resignFirstResponder];
//    [_tf_14 resignFirstResponder];
//    [_tf_15 resignFirstResponder];
//    [_tf_16 resignFirstResponder];
//    [_tf_17 resignFirstResponder];
//    [_tf_18 resignFirstResponder];
//    [_tf_19 resignFirstResponder];
//    [_tf_20 resignFirstResponder];
//    [_tf_21 resignFirstResponder];
}

- (void)hidesKeyboard{
    [self.view endEditing:YES];
    _gesture.enabled = NO;
    [self resumeView];
}
- (void)keyboardWillShow {
    _gesture.enabled = YES;
}
-(void)textFieldDidBeginEditing:(UITextField *)textField{
    CGPoint pt = [textField convertPoint:CGPointMake(0, 0) toView:_scrollView];
    if((pt.y - _scrollView.contentOffset.y)+ _scrollView.frame.origin.x + 264 + 10 + 30 > SCREEN_HEIGHT){
        [self moveView:(pt.y - _scrollView.contentOffset.y)+ _scrollView.frame.origin.x + 264 + 10 + 30 - SCREEN_HEIGHT];
    }else{
        moveHeight = 0;
    }
}

bool isHaveDian = YES;


- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    if ([textField.text rangeOfString:@"."].location == NSNotFound) {
        isHaveDian = NO;
    }
    if ([string length] > 0) {
        
        unichar single = [string characterAtIndex:0];//当前输入的字符
        if ((single >= '0' && single <= '9') || single == '.') {//数据格式正确
            
            //首字母不能为0和小数点
            if([textField.text length] == 0){
                if(single == '.') {
                    [self showError:@"亲，第一个数字不能为小数点"];
                    [textField.text stringByReplacingCharactersInRange:range withString:@""];
                    return NO;
                }
//                if (single == '0') {
//                    [self showError:@"亲，第一个数字不能为0"];
//                    [textField.text stringByReplacingCharactersInRange:range withString:@""];
//                    return NO;
//                }
            }
            
            //输入的字符是否是小数点
            if (single == '.') {
                if(!isHaveDian)//text中还没有小数点
                {
                    isHaveDian = YES;
                    return YES;
                    
                }else{
                    [self showError:@"亲，您已经输入过小数点了"];
                    [textField.text stringByReplacingCharactersInRange:range withString:@""];
                    return NO;
                }
            }else{
                if (isHaveDian) {//存在小数点
                    
                    //判断小数点的位数
                    NSRange ran = [textField.text rangeOfString:@"."];
                    if (range.location - ran.location <= 2) {
                        return YES;
                    }else{
                        [self showError:@"亲，您最多输入两位小数"];
                        return NO;
                    }
                }else{
                    return YES;
                }
            }
        }else{//输入的数据格式不正确
            [self showError:@"亲，您输入的格式不正确"];
            [textField.text stringByReplacingCharactersInRange:range withString:@""];
            return NO;
        }
    }
    else
    {
        return YES;
    }
}

- (void)showError:(NSString *)errorString
{
    UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:errorString delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
    [alert show];
}


-(void)moveView:(NSInteger)offset{
    moveHeight = offset;
    NSTimeInterval animationDuration=0.30f;
    [UIView beginAnimations:@"ResizeForKeyboard" context:nil];
    [UIView setAnimationDuration:animationDuration];
    float width = self.view.frame.size.width;
    float height = self.view.frame.size.height;
    //上移30个单位，按实际情况设置
    CGRect rect=CGRectMake(0.0f,self.view.frame.origin.y-offset,width,height);
    self.view.frame=rect;
    [UIView commitAnimations];
}

-(void)resumeView
{
    NSTimeInterval animationDuration=0.30f;
    [UIView beginAnimations:@"ResizeForKeyboard" context:nil];
    [UIView setAnimationDuration:animationDuration];
    float width = self.view.frame.size.width;
    float height = self.view.frame.size.height;
    CGRect rect=CGRectMake(0.0f,self.view.frame.origin.y+
                           moveHeight,width,height);
    self.view.frame=rect;
    [UIView commitAnimations]; 
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (IBAction)btn_click_ok:(id)sender {
    NSString *msg = [NSString alloc];
    if([_tf_1.text floatValue] <= [[[datas objectAtIndex:0] objectForKey:@"RmdScale"] floatValue]&&
       [_tf_2.text floatValue] <= [[[datas objectAtIndex:1] objectForKey:@"RmdScale"] floatValue]&&
       [_tf_3.text floatValue] <= [[[datas objectAtIndex:2] objectForKey:@"RmdScale"] floatValue]&&
       [_tf_4.text floatValue] <= [[[datas objectAtIndex:3] objectForKey:@"RmdScale"] floatValue]&&
       [_tf_5.text floatValue] <= [[[datas objectAtIndex:4] objectForKey:@"RmdScale"] floatValue]&&
       [_tf_6.text floatValue] <= [[[datas objectAtIndex:5] objectForKey:@"RmdScale"] floatValue]&&
       [_tf_7.text floatValue] <= [[[datas objectAtIndex:6] objectForKey:@"RmdScale"] floatValue]
//       &&
//       [_tf_8.text floatValue] <= [[[datas objectAtIndex:7] objectForKey:@"RmdScale"] floatValue]&&
//       [_tf_9.text floatValue] <= [[[datas objectAtIndex:8] objectForKey:@"RmdScale"] floatValue]&&
//       [_tf_10.text floatValue] <= [[[datas objectAtIndex:9] objectForKey:@"RmdScale"] floatValue]&&
//       [_tf_11.text floatValue] <= [[[datas objectAtIndex:10] objectForKey:@"RmdScale"] floatValue]&&
//       [_tf_12.text floatValue] <= [[[datas objectAtIndex:11] objectForKey:@"RmdScale"] floatValue]&&
//       [_tf_13.text floatValue] <= [[[datas objectAtIndex:12] objectForKey:@"RmdScale"] floatValue]&&
//       [_tf_14.text floatValue] <= [[[datas objectAtIndex:13] objectForKey:@"RmdScale"] floatValue]&&
//       [_tf_15.text floatValue] <= [[[datas objectAtIndex:14] objectForKey:@"RmdScale"] floatValue]&&
//       [_tf_16.text floatValue] <= [[[datas objectAtIndex:15] objectForKey:@"RmdScale"] floatValue]&&
//       [_tf_17.text floatValue] <= [[[datas objectAtIndex:16] objectForKey:@"RmdScale"] floatValue]&&
//       [_tf_18.text floatValue] <= [[[datas objectAtIndex:17] objectForKey:@"RmdScale"] floatValue]&&
//       [_tf_19.text floatValue] <= [[[datas objectAtIndex:18] objectForKey:@"RmdScale"] floatValue]&&
//       [_tf_20.text floatValue] <= [[[datas objectAtIndex:19] objectForKey:@"RmdScale"] floatValue]
       ){
        msg = [NSString stringWithFormat:@"%@*%@*%@*%@*%@*%@|%@*%@*%@*%@*%@*%@|%@*%@*%@*%@*%@*%@|%@*%@*%@*%@*%@*%@|%@*%@*%@*%@*%@*%@|%@*%@*%@*%@*%@*%@|%@*%@*%@*%@*%@*%@",
//               |%@*%@*%@*%@*%@*%@|%@*%@*%@*%@*%@*%@|%@*%@*%@*%@*%@*%@|%@*%@*%@*%@*%@*%@|%@*%@*%@*%@*%@*%@|%@*%@*%@*%@*%@*%@|%@*%@*%@*%@*%@*%@|%@*%@*%@*%@*%@*%@|%@*%@*%@*%@*%@*%@|%@*%@*%@*%@*%@*%@|%@*%@*%@*%@*%@*%@|%@*%@*%@*%@*%@*%@|%@*%@*%@*%@*%@*%@|%@*%@*%@*%@*%@*%@",
               [[datas objectAtIndex:0] objectForKey:@"Index"],[[datas objectAtIndex:0] objectForKey:@"Scale"],_tf_1.text,[[datas objectAtIndex:0] objectForKey:@"RmdScale"],[[datas objectAtIndex:0] objectForKey:@"LottID"],[[datas objectAtIndex:0] objectForKey:@"LottName"],
               [[datas objectAtIndex:1] objectForKey:@"Index"],[[datas objectAtIndex:1] objectForKey:@"Scale"],_tf_2.text,[[datas objectAtIndex:1] objectForKey:@"RmdScale"],[[datas objectAtIndex:1] objectForKey:@"LottID"],[[datas objectAtIndex:1] objectForKey:@"LottName"],
               [[datas objectAtIndex:2] objectForKey:@"Index"],[[datas objectAtIndex:2] objectForKey:@"Scale"],_tf_3.text,[[datas objectAtIndex:2] objectForKey:@"RmdScale"],[[datas objectAtIndex:2] objectForKey:@"LottID"],[[datas objectAtIndex:2] objectForKey:@"LottName"],
               [[datas objectAtIndex:3] objectForKey:@"Index"],[[datas objectAtIndex:3] objectForKey:@"Scale"],_tf_4.text,[[datas objectAtIndex:3] objectForKey:@"RmdScale"],[[datas objectAtIndex:3] objectForKey:@"LottID"],[[datas objectAtIndex:3] objectForKey:@"LottName"],
               [[datas objectAtIndex:4] objectForKey:@"Index"],[[datas objectAtIndex:4] objectForKey:@"Scale"],_tf_5.text,[[datas objectAtIndex:4] objectForKey:@"RmdScale"],[[datas objectAtIndex:4] objectForKey:@"LottID"],[[datas objectAtIndex:4] objectForKey:@"LottName"],
               [[datas objectAtIndex:5] objectForKey:@"Index"],[[datas objectAtIndex:5] objectForKey:@"Scale"],_tf_6.text,[[datas objectAtIndex:5] objectForKey:@"RmdScale"],[[datas objectAtIndex:5] objectForKey:@"LottID"],[[datas objectAtIndex:5] objectForKey:@"LottName"],
               [[datas objectAtIndex:6] objectForKey:@"Index"],[[datas objectAtIndex:6] objectForKey:@"Scale"],_tf_7.text,[[datas objectAtIndex:6] objectForKey:@"RmdScale"],[[datas objectAtIndex:6] objectForKey:@"LottID"],[[datas objectAtIndex:6] objectForKey:@"LottName"]
//               ,
//               [[datas objectAtIndex:7] objectForKey:@"Index"],[[datas objectAtIndex:7] objectForKey:@"Scale"],_tf_8.text,[[datas objectAtIndex:7] objectForKey:@"RmdScale"],[[datas objectAtIndex:7] objectForKey:@"LottID"],[[datas objectAtIndex:7] objectForKey:@"LottName"],
//               [[datas objectAtIndex:8] objectForKey:@"Index"],[[datas objectAtIndex:8] objectForKey:@"Scale"],_tf_9.text,[[datas objectAtIndex:8] objectForKey:@"RmdScale"],@"28",[[datas objectAtIndex:8] objectForKey:@"LottName"],
//               [[datas objectAtIndex:9] objectForKey:@"Index"],[[datas objectAtIndex:9] objectForKey:@"Scale"],_tf_10.text,[[datas objectAtIndex:9] objectForKey:@"RmdScale"],@"39",[[datas objectAtIndex:9] objectForKey:@"LottName"],
//               [[datas objectAtIndex:10] objectForKey:@"Index"],[[datas objectAtIndex:10] objectForKey:@"Scale"],_tf_11.text,[[datas objectAtIndex:10] objectForKey:@"RmdScale"],@"45",[[datas objectAtIndex:10] objectForKey:@"LottName"],
//               [[datas objectAtIndex:11] objectForKey:@"Index"],[[datas objectAtIndex:11] objectForKey:@"Scale"],_tf_12.text,[[datas objectAtIndex:11] objectForKey:@"RmdScale"],@"62",[[datas objectAtIndex:11] objectForKey:@"LottName"],
//               [[datas objectAtIndex:12] objectForKey:@"Index"],[[datas objectAtIndex:12] objectForKey:@"Scale"],_tf_13.text,[[datas objectAtIndex:12] objectForKey:@"RmdScale"],@"63",[[datas objectAtIndex:12] objectForKey:@"LottName"],
//               [[datas objectAtIndex:13] objectForKey:@"Index"],[[datas objectAtIndex:13] objectForKey:@"Scale"],_tf_14.text,[[datas objectAtIndex:13] objectForKey:@"RmdScale"],@"64",[[datas objectAtIndex:13] objectForKey:@"LottName"],
//               [[datas objectAtIndex:14] objectForKey:@"Index"],[[datas objectAtIndex:14] objectForKey:@"Scale"],_tf_15.text,[[datas objectAtIndex:14] objectForKey:@"RmdScale"],@"73",[[datas objectAtIndex:14] objectForKey:@"LottName"],
//               [[datas objectAtIndex:15] objectForKey:@"Index"],[[datas objectAtIndex:15] objectForKey:@"Scale"],_tf_16.text,[[datas objectAtIndex:15] objectForKey:@"RmdScale"],@"90",[[datas objectAtIndex:15] objectForKey:@"LottName"],
//               [[datas objectAtIndex:16] objectForKey:@"Index"],[[datas objectAtIndex:16] objectForKey:@"Scale"],_tf_17.text,[[datas objectAtIndex:16] objectForKey:@"RmdScale"],@"90",[[datas objectAtIndex:16] objectForKey:@"LottName"],
//               [[datas objectAtIndex:17] objectForKey:@"Index"],[[datas objectAtIndex:17] objectForKey:@"Scale"],_tf_18.text,[[datas objectAtIndex:17] objectForKey:@"RmdScale"],@"90",[[datas objectAtIndex:17] objectForKey:@"LottName"],
//               [[datas objectAtIndex:18] objectForKey:@"Index"],[[datas objectAtIndex:18] objectForKey:@"Scale"],_tf_19.text,[[datas objectAtIndex:18] objectForKey:@"RmdScale"],@"91",[[datas objectAtIndex:18] objectForKey:@"LottName"],
//               [[datas objectAtIndex:19] objectForKey:@"Index"],[[datas objectAtIndex:19] objectForKey:@"Scale"],_tf_20.text,[[datas objectAtIndex:19] objectForKey:@"RmdScale"],@"91",[[datas objectAtIndex:19] objectForKey:@"LottName"],
//               [[datas objectAtIndex:20] objectForKey:@"Index"],[[datas objectAtIndex:20] objectForKey:@"Scale"],_tf_21.text,[[datas objectAtIndex:20] objectForKey:@"RmdScale"],@"91",[[datas objectAtIndex:20] objectForKey:@"LottName"]
               ];
        SetYongJin* setyong = [[SetYongJin alloc] init];
        setyong.userid = subuserid;
        setyong.msg = msg;
        setyong.isPro = ([_cb_isCMD isSelected]?@"true":@"false");
        setyong.delegate = self;
        [JddCommonFunction setWaitingViewHidden:NO fromController:self];
        [[JddGlobalParameter sharedInstance].operationQueue addOperation:setyong];
    }else{
        UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"为下级设置的佣金不能超过自身佣金" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alert show];
    }
}

-(void)SetYongJinResult:(NSData *)result{
    [JddCommonFunction setWaitingViewHidden:YES fromController:self];
    NSDictionary *ReDic = [NSJSONSerialization JSONObjectWithData:result options:NSJSONReadingMutableContainers error:nil];
    if([[ReDic objectForKey:@"Code"] intValue] == 0)
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"设置佣金" message:@"设置佣金成功" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil,nil ];
        [alert show];
    }else{
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"设置佣金" message:[ReDic objectForKey:@"Data"] delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil,nil ];
        [alert show];
    }
}

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if([alertView.message isEqualToString:@"设置佣金成功"]){
        [self.navigationController popViewControllerAnimated:YES];
    }
}

- (IBAction)btn_click_cancel:(id)sender {
}
@end
